/*
 *  Copyright (c) 2010 Brian Stanek <bstanek@gmail.com>
 *
 *  Permission is hereby granted, free of charge, to any person
 *  obtaining a copy of this software and associated documentation
 *  files (the "Software"), to deal in the Software without
 *  restriction, including without limitation the rights to use,
 *  copy, modify, merge, publish, distribute, sublicense, and/or sell
 *  copies of the Software, and to permit persons to whom the
 *  Software is furnished to do so, subject to the following
 *  conditions:
 *
 *  The above copyright notice and this permission notice shall be
 *  included in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 *  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 *  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *  OTHER DEALINGS IN THE SOFTWARE.
 */

package guice
{

import guice.spi.BindingScopingVisitor;
import guice.spi.BindingTargetVisitor;
import guice.spi.Element;

/**
 *  A mapping from a <code>Key</code> (type and optional annotation) to the
 *  strategy for getting instances of the type.
 *
 * <p>They exist on both modules and on injectors, and their behaviour is different for each:
 * <ul>
 *     <li><strong>Module bindings</strong> are incomplete and cannot be used to provide instances.
 *         This is because the applicable scopes and interceptors may not be known until an injector
 *         is created. From a tool's perspective, module bindings are like the injector's source
 *         code. They can be inspected or rewritten, but this analysis must be done statically.</li>
 *     <li><strong>Injector bindings</strong> are complete and valid and can be used to provide
 *         instances. From a tools' perspective, injector bindings are like reflection for an
 *         injector. They have full runtime information, including the complete graph of injections
 *         necessary to satisfy a binding.</li>
 * </ul>
 *
 */
public interface Binding extends Element
{

    //--------------------------------------------------------------------------
    //
    //  Methods
    //
    //--------------------------------------------------------------------------

    function acceptScopingVisitor(visitor:BindingScopingVisitor):Boolean;

    function acceptTargetVisitor(visitor:BindingTargetVisitor):Boolean;

    /**
     *  Returns the <code>Key</code> for this <code>Binding</code>.
     *
     *  @return The <code>Key</code> for this <code>Binding</code>.
     */
    function getKey():Key;

    /**
     *  Returns the scoped <code>Provider</code> Guice uses to fulfill requests
     *  for this <code>Binding</code>.
     *
     *  <p>
     *  This method is only supported on <code>Binding</code>s returned from
     *  an <code>Injector</code>.
     *  </p>
     *
     *  @throws flash.errors.IllegalOperationError when invoked on a Module
     *  Binding.
     *
     *  @return The scoped <code>Provider</code> for this <code>Binding</code>.
     */
    function getProvider():Provider;

}

}
